package com.bosssoft.hr.train.jsp.example.tag;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.SimpleTagSupport;
import java.io.IOException;
import java.io.StringWriter;

/**
 * @description: 定义<boss:userTag /> 标签
 * @author: Administrator
 * @create: 2020-05-29 13:50
 * @since
 **/
public class UserTag extends SimpleTagSupport {
    private String user;

    StringWriter sw = new StringWriter();

    @Override
    public void doTag() throws JspException, IOException {
        if (user!=null){
            JspWriter out = getJspContext().getOut();
            out.println(user);
        }else {
            getJspBody().invoke(sw);
            getJspContext().getOut().print(sw.toString());
        }
    }
}
